package com.example;

import com.example.annotation.Inject;
import com.example.factory.PropertiesFactory;
import com.example.factory.ServiceFactory;
import com.example.service.IBodyService;
import com.example.service.IService;
import com.example.service.impl.MyServiceImpl;
import com.example.utils.ClassPathXMLApplicationContext;

import java.util.List;

/**
 * Created by Administrator on 2016/12/24.
 */
public class Main {

    public static void main(String[] args){

//        String implName = PropertiesFactory.getValue("myservice");
//        System.out.println(implName);

//        Main main = new Main();
//        main.service.sayHello();

//        ClassPathXMLApplicationContext context = new ClassPathXMLApplicationContext("applicationContext.xml");

        ClassPathXMLApplicationContext context = ClassPathXMLApplicationContext.getInstance();
        IService service  = (IService) context.getBean("myService");
        service.sayHello();

    }


    private static void serviceTest() {
        //IService service = ServiceFactory.factory(MyServiceImpl.class.getName());
        IBodyService service = (IBodyService) ServiceFactory.factory(null);

        service.sayHello();
        System.out.println("Count = " + service.getCount());

        for (int i = 0; i < 15; i++) {
            ServiceFactory.factory(MyServiceImpl.class.getName());
            ServiceFactory.factory(Main.class.getName());
        }

        List list = service.findAll();
        list.forEach(System.out::println);
    }

}
